package com.linkstec.java8;

import java.time.Duration;
import java.time.Instant;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class LocalTimeTest {

	public static void main(String[] args) {
		LocalTime localTime = LocalTime.now();
		LocalTime eightHalfTime = LocalTime.parse("08:30:00.000");
		LocalTime eightHalfTime11 = LocalTime.parse("17:00:00.000");
		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HHmm");
		LocalTime aaa = LocalTime.parse("2300", dtf);

		System.out.println(aaa);
		System.out.println(localTime);
		System.out.println(eightHalfTime);

		Duration duration = Duration.between(eightHalfTime, eightHalfTime11);

		System.out.println(duration.toHours() + "小时");
		System.out.println(duration.minusHours(duration.toHours()).toMinutes() + "分钟");
		if (localTime.isBefore(eightHalfTime)) {
			System.out.println("before");
		}
		if (localTime.isAfter(eightHalfTime11)) {
			System.out.println("after");
		}

		Instant timestamp = Instant.now();
		System.out.println(timestamp);

	}

}
